<template>
	<view class="myPage">
		<view class="header">
			<view class="header-img">
				<image :src=uimg mode="aspectFit"></image>
				<view class="userName">
					{{uname}}
				</view>
			</view>
			<view class="setting" @click="gotoSetting">
				<image src="../../static/images/my/sz.png" mode="aspectFit"></image>
			</view>
		</view>
		<view class="content">
			<view class="order1" @click="gotoorderCenter()">
				<text class="title" >订单中心</text>
				<view class="oderList" >
					<view v-for="(item,index) in oderList" :key="item.id"  class="orderItem">
						<image :src=item.img mode=""></image>
						<view>{{item.name}}</view>
					</view>
				</view>
			</view>
			<view class="order2">
				<text class="title">常用服务</text>
				<view class="oderList">
						<view v-for="(item,index) in serviceList" :key="item.id"  @click="gotoCollect(item.id)" class="orderItem">
							<image :src=item.img mode=""></image>
							<view>{{item.name}}</view>
						</view>
				</view>
			</view>
		</view>
		
	</view>
</template>

<script>
	export default {
		name: "form-component",
		data(){
			return {
				uname:"蓝色心情",
				uimg:"../../static/images/logo.png",
				indexs:0,
				oderList:[
					{id:'1',img:'../../static/images/my/pay.png',name:'待支付'},
					{id:'2',img:'../../static/images/my/ruzhu.png',name:'待入住'},
					{id:'3',img:'../../static/images/my/pj.png',name:'待评价'},
					{id:'4',img:'../../static/images/my/dd.png',name:'全部订单'},
				],
				serviceList:[
					{id:'1',img:'../../static/images/my/sc.png',name:'我的收藏'},
					{id:'2',img:'../../static/images/my/jd.png',name:'曾住酒店'},
					{id:'3',img:'../../static/images/my/kaquan.png',name:'卡券包'},
					{id:'4',img:'../../static/images/my/lvke.png',name:'常用旅客'},
					{id:'5',img:'../../static/images/my/yijian.png',name:'意见反馈'}
				],
			}
		},
		onLoad() {
			// 查询用户信息
			this.queryUser()
		},
		// 页面挂载完成时
		mounted() {
		},
		methods:{
				// 查询
			queryUser() {
				let uid = "6413d0a49b7fa0a869a59072"
				uni.request({
					url:'http://127.0.0.1:3030/queryUser',
					method:'POST',
					data:{
						_id:uid
					},
					success:(res)=>{
						// let index = 0
						console.log(res)
						let result = res.data.data
						this.uname = result[0].uname
						this.uimg = result[0].uimg
						if(result == "查询成功"){
							uni.showToast({
								title:result,
								icon:'success'
							})
							// else{
							// uni.showToast({
							// 	title:result,
							// 	icon:'error'
							// })
						}
					}
				})
			},
			gotoSetting(){
				// 跳转到设置页
				uni.navigateTo({url:'../setting/setting'})
			},
			// 跳转到订单中心
			gotoorderCenter() {
				uni.navigateTo({url:'../dingdanCenter/dingdanCenter'})
			},
			gotoCollect(id) {
					if (id === 1 || id === 2) {
						// 跳转到我的收藏页面
						uni.navigateTo({
							url:'../collect/collect'
						})
					}
				}
		},
	}
</script>

<style>
.myPage{
	position: absolute;
	width: 100%;
	height: 100%;
	background-color: #F1F3F4;
}
/* 头部局域 */
.header {
	/* background-color: skyblue; */
	display: flex;
	width: 100%;
	height: 220rpx;
	justify-content: space-between;
}
.header-img {
	display: flex;
	align-items: center;
}
.header-img image {
	background-color: black;
	width: 200rpx;
	height: 200rpx;
	border-radius: 100rpx;
}
.userName {
	margin-top: 50rpx;
	margin-left: 40rpx;
	/* margin-bottom: 20rpx; */
	font-size: 32rpx;
}
.setting image {
	width: 80rpx;
	height: 100rpx;
	margin-right: 40rpx;
	margin-top: 50rpx ;
	align-items: center;
}
.content {
	width: 100%;
}
/* 订单部分 */
.order1 {
	height: 240rpx;
	margin-top: 40rpx;
	display: flex;
	flex-direction: column;
	border: 3rpx 3rpx solid #8a8a8a;
	border-radius: 20rpx;
	background-color: white;
}
.order2 {
	margin-top: 40rpx;
	display: flex;
	flex-direction: column;
	background-color: white;
}
.title {
	font-size: 36rpx;
	font-weight: bold;
	padding: 0 20rpx;
}
.oderList {
	margin: 0 20rpx;
	display: flex;
	flex-wrap: wrap;
	
}
.orderItem {
	margin-top: 30rpx;
	margin-bottom: 20rpx;
	width: 25%;
	flex-wrap: wrap;
	display: flex;
	flex-direction: column;
	justify-content: center;
	align-items: center;
}
.orderItem image {
	margin-top: 20rpx;
	width: 50rpx;
	height: 50rpx;
}
</style>
